﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace Hyperbolic.Converters
{
    public class LocationConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue)
                return Binding.DoNothing;

            double __dimension = System.Convert.ToDouble(values[0]);
            double __size = System.Convert.ToDouble(values[1]);
            __dimension -= __size / 2;
            return __dimension;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("Cannot convert back");
        }

        #endregion
    }
}
